<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加考试</title>
<%@include file="/view/common/js-css.jsp" %>
<script type="text/javascript" src="<%=request.getContextPath() %>/static/My97DatePicker/WdatePicker.js"></script>
<style>
	#errorInfo{
		color: red;
		position: absolute;
 	 	left: 325px;
  		top: 0px;
  		width: 200px;
	}

</style>
</head>
<body>
	<div id="frameWrapper" class="frameWrapper">
	 <div class="titlebar">
		<a class="btn btn-getionfo" href="javascript:;"><i class="fa fa-upload"></i>&nbsp;&nbsp;导入Excel</a> <p>当前位置：考试管理<span>/</span>添加考试</p>
	 </div>
	 
	<div class="formbar">
		<form name="addGrade" action="${pageContext.request.contextPath }/ExamServlet?command=add" method="post" onsubmit="return validate();">
		    <div class="form_control">
		    <span class="input-name">考试科目：</span>
		      <select class="select required" data-valid="isNonEmpty" data-error="班级必填" name="examSubjectId">
				    	<option value="">————————请选择————————</option>
						<c:forEach items="${subjectList }" var="subject">
				    		<option value="${subject.subject_id }">${subject.subject_name }</option>
				    	</c:forEach>
			  </select>
		    </div>
		    <div class="form_control form_control">
		     <span class="input-name">考试时间：</span>
		     <input type="text" id="d241" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate" style="width:300px; height: 40px;" name="examTime" onblur="showInfo()" />
		     <span id="errorInfo"></span>
		    </div>
		    <div class="form_control">
		    <span class="input-name">参考班级：</span>
		      <select class="select required" data-valid="isNonEmpty" data-error="班级必选" name="examGradeId">
				    	<option value="">————————请选择————————</option>
						<c:forEach items="${gradeList }" var="grade">
				    		<option value="${grade.grade_id }">${grade.grade_name }</option>
				    	</c:forEach>
			  </select>
		    </div>
		    <div class="form_control">
		    <span class="input-name">考试试题：</span>
		      <select class="select required" data-valid="isNonEmpty" data-error="考试试题必选" name="examPaperId">
				    	<option value="">————————请选择————————</option>
						<c:forEach items="${paperList }" var="paper">
				    		<option value="${paper.paper_id }">${paper.paper_name }</option>
				    	</c:forEach>
			  </select>
		    </div>
		    <div class="form_control">
		    <span class="input-name">发布人：</span>
		      <select class="select required" data-valid="isNonEmpty" data-error="发布人必选" name="examUserId">
				    	<option value="">————————请选择————————</option>
						<c:forEach items="${userList }" var="user">
				    		<option value="${user.user_id }">${user.username }</option>
				    	</c:forEach>
			  </select>
		    </div>
		     <div class="submit">
     			<input type="submit" value="立即提交" />
			</div>
			</form>
	</div>
</div>
<script>
	function validate(){
		var examTime = document.getElementById('d241').value;
		if (examTime == '') {
			document.getElementById('errorInfo').innerHTML = '考试时间不能为空';
			return false;
		} else {
			document.getElementById('errorInfo').innerHTML = '';
			return true;
		}
	}
	
	function showInfo(){
		var examTime = document.getElementById('d241').value;
		if (examTime == '') {
			document.getElementById('errorInfo').innerHTML = '考试时间不能为空';
		} else {
			document.getElementById('errorInfo').innerHTML = '';
		}
	}
</script>
</body>
</html>